
package ru.kpm.rectpack.frames;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import ru.kpm.rectpack.represent.Container2DModel;
import ru.kpm.rectpack.represent.Container3DModel;
import ru.kpm.rectpack.represent.Pallet3DModel;
import ru.kpm.rectpack.represent.InputData;
import ru.kpm.rectpack.represent.Model2D;
import ru.kpm.rectpack.represent.OutputData;
import ru.kpm.rectpack.represent.Model3D;
import ru.kpm.rectpack.represent.Pallet2DModel;

/**
 *
 * @author Podorov Alexander
 */

public class MainFrame extends JFrame
{    
    public MainFrame()
    {
        initComponents();
        initUserComponents();
    }

    private void initUserComponents()
    {
        inputData = new InputData();
        outputData = new OutputData();

        container3D = new Container3DModel(inputData, outputData);        
        pallet3D = new Pallet3DModel(inputData, outputData);
        container2D = new Container2DModel(inputData, outputData);
        pallet2D = new Pallet2DModel(inputData, outputData);

        jPanel5.setLayout(new BorderLayout());
        jPanel5.add(container3D, BorderLayout.CENTER);
        jPanel7.setLayout(new BorderLayout());
        jPanel7.add(pallet3D, BorderLayout.CENTER);
        jPanel3.setLayout(new BorderLayout());
        jPanel3.add(container2D, BorderLayout.CENTER);
        jPanel6.setLayout(new BorderLayout());
        jPanel6.add(pallet2D, BorderLayout.CENTER);        

        jTable6.getColumnModel().getColumn(0).setPreferredWidth(230);
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new JDesktopPane();
        jInternalFrame1 = new JInternalFrame();
        jTabbedPane2 = new JTabbedPane();
        jPanel3 = new JPanel();
        jPanel5 = new JPanel();
        jInternalFrame2 = new JInternalFrame();
        jTabbedPane1 = new JTabbedPane();
        jPanel1 = new JPanel();
        jScrollPane1 = new JScrollPane();
        jTable1 = new JTable();
        jLabel1 = new JLabel();
        jLabel2 = new JLabel();
        jScrollPane2 = new JScrollPane();
        jTable2 = new JTable();
        jPanel2 = new JPanel();
        jScrollPane3 = new JScrollPane();
        jTable3 = new JTable();
        jScrollPane4 = new JScrollPane();
        jTable4 = new JTable();
        jLabel3 = new JLabel();
        jLabel4 = new JLabel();
        jLabel5 = new JLabel();
        jTextField1 = new JTextField();
        jPanel4 = new JPanel();
        jScrollPane5 = new JScrollPane();
        jTable5 = new JTable();
        jLabel6 = new JLabel();
        jLabel8 = new JLabel();
        jTextField2 = new JTextField();
        jLabel9 = new JLabel();
        jTextField3 = new JTextField();
        jButton1 = new JButton();
        jInternalFrame3 = new JInternalFrame();
        jScrollPane6 = new JScrollPane();
        jTable6 = new JTable();
        jInternalFrame4 = new JInternalFrame();
        jTabbedPane3 = new JTabbedPane();
        jPanel6 = new JPanel();
        jPanel7 = new JPanel();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setTitle("3D Упаковка");

        jInternalFrame1.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        jInternalFrame1.setIconifiable(true);
        jInternalFrame1.setMaximizable(true);
        jInternalFrame1.setResizable(true);
        jInternalFrame1.setTitle("Контейнер");
        jInternalFrame1.setVisible(true);

        jTabbedPane2.setFont(new Font("Tahoma", 1, 11));

        jPanel3.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

        GroupLayout jPanel3Layout = new GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 533, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 257, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("2D", jPanel3);

        jPanel5.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

        GroupLayout jPanel5Layout = new GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 533, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 257, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("3D", jPanel5);

        GroupLayout jInternalFrame1Layout = new GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(Alignment.LEADING)
            .addComponent(jTabbedPane2, GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(Alignment.LEADING)
            .addComponent(jTabbedPane2, GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
        );

        jInternalFrame1.setBounds(10, 10, 550, 320);
        jDesktopPane1.add(jInternalFrame1, JLayeredPane.DEFAULT_LAYER);

        jInternalFrame2.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        jInternalFrame2.setIconifiable(true);
        jInternalFrame2.setTitle("Данные");
        jInternalFrame2.setMinimumSize(new Dimension(400, 325));
        jInternalFrame2.setVisible(true);

        jTabbedPane1.setFont(new Font("Tahoma", 1, 11));

        jPanel1.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

        jTable1.setFont(new Font("Tahoma", 1, 11));
        jTable1.setModel(new DefaultTableModel(
            new Object [][] {
                {"1000", "800", "780"}
            },
            new String [] {
                "Длина", "Ширина", "Высота"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jLabel1.setFont(new Font("Tahoma", 1, 11));
        jLabel1.setText("Размеры:");

        jLabel2.setFont(new Font("Tahoma", 1, 11));
        jLabel2.setText("Отступы:");

        jTable2.setFont(new Font("Tahoma", 1, 11));
        jTable2.setModel(new DefaultTableModel(
            new Object [][] {
                {"20", "20", "20"}
            },
            new String [] {
                "По Длине", "По Ширине", "По Высоте"
            }
        ));
        jScrollPane2.setViewportView(jTable2);

        GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(jLabel2, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addComponent(jLabel1, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(55, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Контейнер", jPanel1);

        jPanel2.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

        jTable3.setFont(new Font("Tahoma", 1, 11));
        jTable3.setModel(new DefaultTableModel(
            new Object [][] {
                {"400", "300"}
            },
            new String [] {
                "Длина", "Ширина"
            }
        ));
        jScrollPane3.setViewportView(jTable3);

        jTable4.setFont(new Font("Tahoma", 1, 11));
        jTable4.setModel(new DefaultTableModel(
            new Object [][] {
                {"20", "20", "20"}
            },
            new String [] {
                "По Длине", "По Ширине", "По Высоте"
            }
        ));
        jScrollPane4.setViewportView(jTable4);

        jLabel3.setFont(new Font("Tahoma", 1, 11));
        jLabel3.setText("Размеры:");

        jLabel4.setFont(new Font("Tahoma", 1, 11));
        jLabel4.setText("Отступы:");

        jLabel5.setFont(new Font("Tahoma", 1, 11));
        jLabel5.setText("Количество уровней:");

        jTextField1.setEditable(false);
        jTextField1.setFont(new Font("Tahoma", 1, 11));
        jTextField1.setText("2");

        GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(jScrollPane3, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createParallelGroup(Alignment.TRAILING, false)
                        .addComponent(jTextField1, Alignment.LEADING)
                        .addComponent(jLabel5, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jScrollPane4, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addComponent(jLabel3, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addComponent(jLabel4, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Паллета", jPanel2);

        jPanel4.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

        jTable5.setFont(new Font("Tahoma", 1, 11));
        jTable5.setModel(new DefaultTableModel(
            new Object [][] {
                {"150", "100", "100"}
            },
            new String [] {
                "Длина", "Ширина", "Высота"
            }
        ));
        jScrollPane5.setViewportView(jTable5);

        jLabel6.setFont(new Font("Tahoma", 1, 11));
        jLabel6.setText("Размеры:");

        jLabel8.setFont(new Font("Tahoma", 1, 11));
        jLabel8.setText("Количество слоев на 1 уровне:");

        jTextField2.setFont(new Font("Tahoma", 1, 11));
        jTextField2.setText("4");

        jLabel9.setFont(new Font("Tahoma", 1, 11));
        jLabel9.setText("Количество слоев на 2 уровне:");

        jTextField3.setFont(new Font("Tahoma", 1, 11));
        jTextField3.setText("3");

        GroupLayout jPanel4Layout = new GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(Alignment.LEADING)
                            .addComponent(jScrollPane5, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                            .addComponent(jLabel6, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(Alignment.TRAILING)
                            .addComponent(jTextField3, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                            .addComponent(jLabel9, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel8, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jTextField2, GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
                        .addGap(195, 195, 195))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addComponent(jLabel8)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Коробка", jPanel4);

        jButton1.setFont(new Font("Tahoma", 1, 11));
        jButton1.setText("Расчет");
        jButton1.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        GroupLayout jInternalFrame2Layout = new GroupLayout(jInternalFrame2.getContentPane());
        jInternalFrame2.getContentPane().setLayout(jInternalFrame2Layout);
        jInternalFrame2Layout.setHorizontalGroup(
            jInternalFrame2Layout.createParallelGroup(Alignment.LEADING)
            .addComponent(jTabbedPane1, GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
            .addGroup(jInternalFrame2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(254, Short.MAX_VALUE))
        );
        jInternalFrame2Layout.setVerticalGroup(
            jInternalFrame2Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(Alignment.TRAILING, jInternalFrame2Layout.createSequentialGroup()
                .addComponent(jTabbedPane1, GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addGap(15, 15, 15))
        );

        jInternalFrame2.setBounds(570, 10, 400, 320);
        jDesktopPane1.add(jInternalFrame2, JLayeredPane.DEFAULT_LAYER);

        jInternalFrame3.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        jInternalFrame3.setIconifiable(true);
        jInternalFrame3.setTitle("Статистика");
        jInternalFrame3.setVisible(true);

        jTable6.setFont(new Font("Tahoma", 1, 11));
        jTable6.setModel(new DefaultTableModel(
            new Object [][] {
                {"Количество паллет в контейнере", null},
                {"Количество паллет на уровне", null},
                {"Количество коробок в контейнере", null},
                {"Количество коробок в паллете 1 уровня", null},
                {"Количество коробок в паллете 2 уровня", null},
                {"Количество коробок на 1 уровне", null},
                {"Количество коробок на 2 уровне", null},
                {"Высота паллет", null},
                {"Объем контейнера", null},
                {"Полезный объем", null},
                {"Эффективность", null}
            },
            new String [] {
                "Свойство", "Значение"
            }
        ));
        jScrollPane6.setViewportView(jTable6);

        GroupLayout jInternalFrame3Layout = new GroupLayout(jInternalFrame3.getContentPane());
        jInternalFrame3.getContentPane().setLayout(jInternalFrame3Layout);
        jInternalFrame3Layout.setHorizontalGroup(
            jInternalFrame3Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jInternalFrame3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
                .addContainerGap())
        );
        jInternalFrame3Layout.setVerticalGroup(
            jInternalFrame3Layout.createParallelGroup(Alignment.LEADING)
            .addGroup(jInternalFrame3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                .addContainerGap())
        );

        jInternalFrame3.setBounds(570, 370, 400, 260);
        jDesktopPane1.add(jInternalFrame3, JLayeredPane.DEFAULT_LAYER);

        jInternalFrame4.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        jInternalFrame4.setIconifiable(true);
        jInternalFrame4.setMaximizable(true);
        jInternalFrame4.setResizable(true);
        jInternalFrame4.setTitle("Паллета");
        jInternalFrame4.setVisible(true);

        jTabbedPane3.setFont(new Font("Tahoma", 1, 11));

        jPanel6.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

        GroupLayout jPanel6Layout = new GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 533, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 187, Short.MAX_VALUE)
        );

        jTabbedPane3.addTab("2D", jPanel6);

        jPanel7.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

        GroupLayout jPanel7Layout = new GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 533, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 187, Short.MAX_VALUE)
        );

        jTabbedPane3.addTab("3D", jPanel7);

        GroupLayout jInternalFrame4Layout = new GroupLayout(jInternalFrame4.getContentPane());
        jInternalFrame4.getContentPane().setLayout(jInternalFrame4Layout);
        jInternalFrame4Layout.setHorizontalGroup(
            jInternalFrame4Layout.createParallelGroup(Alignment.LEADING)
            .addComponent(jTabbedPane3, GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE)
        );
        jInternalFrame4Layout.setVerticalGroup(
            jInternalFrame4Layout.createParallelGroup(Alignment.LEADING)
            .addComponent(jTabbedPane3, GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
        );

        jInternalFrame4.setBounds(10, 370, 550, 250);
        jDesktopPane1.add(jInternalFrame4, JLayeredPane.DEFAULT_LAYER);

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addComponent(jDesktopPane1, GroupLayout.DEFAULT_SIZE, 990, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addComponent(jDesktopPane1, GroupLayout.DEFAULT_SIZE, 644, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1MouseClicked(MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        try
        {
            inputData.setCx(Integer.parseInt(jTable1.getModel().getValueAt(0, 0).toString()));
            inputData.setCy(Integer.parseInt(jTable1.getModel().getValueAt(0, 1).toString()));
            inputData.setCz(Integer.parseInt(jTable1.getModel().getValueAt(0, 2).toString()));
            inputData.setDcx(Integer.parseInt(jTable2.getModel().getValueAt(0, 0).toString()));
            inputData.setDcy(Integer.parseInt(jTable2.getModel().getValueAt(0, 1).toString()));
            inputData.setDcz(Integer.parseInt(jTable2.getModel().getValueAt(0, 2).toString()));

            inputData.setPx(Integer.parseInt(jTable3.getModel().getValueAt(0, 0).toString()));
            inputData.setPy(Integer.parseInt(jTable3.getModel().getValueAt(0, 1).toString()));
            inputData.setDpx(Integer.parseInt(jTable4.getModel().getValueAt(0, 0).toString()));
            inputData.setDpy(Integer.parseInt(jTable4.getModel().getValueAt(0, 1).toString()));
            inputData.setDpz(Integer.parseInt(jTable4.getModel().getValueAt(0, 2).toString()));
            inputData.setPLayers(Integer.parseInt(jTextField1.getText()));

            inputData.setX(Integer.parseInt(jTable5.getModel().getValueAt(0, 0).toString()));
            inputData.setY(Integer.parseInt(jTable5.getModel().getValueAt(0, 1).toString()));
            inputData.setZ(Integer.parseInt(jTable5.getModel().getValueAt(0, 2).toString()));
            inputData.setLayers1(Integer.parseInt(jTextField2.getText()));
            inputData.setLayers2(Integer.parseInt(jTextField3.getText()));

            outputData.processData(inputData);

            DefaultTableModel model = (DefaultTableModel)jTable6.getModel();
            model.setValueAt(outputData.getPalletsInContainer(), 0, 1);
            model.setValueAt(outputData.getPalletsInLevel(), 1, 1);
            model.setValueAt(outputData.getPacksInContainer(), 2, 1);
            model.setValueAt(outputData.getPacksIn1LevelPallet(), 3, 1);
            model.setValueAt(outputData.getPacksIn2LevelPallet(), 4, 1);
            model.setValueAt(outputData.getPacksIn1Level(), 5, 1);
            model.setValueAt(outputData.getPacksIn2Level(), 6, 1);
            model.setValueAt(outputData.getPalletsHeight(), 7, 1);
            model.setValueAt(outputData.getContainerVolume(), 8, 1);
            model.setValueAt(outputData.getEffectiveContainerVolume(), 9, 1);
            model.setValueAt(outputData.getEfficiency() + " %", 10, 1);

            container3D.rebuild();
            pallet3D.rebuild();
            
            container2D.repaint();            
            pallet2D.repaint();
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }//GEN-LAST:event_jButton1MouseClicked
   
    public static void main(String args[])
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                try
                {
                    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
                    {
                        if (info.getName().equals("Nimbus"))
                        {
                            UIManager.setLookAndFeel(info.getClassName());
                        }
                    }
                }
                catch (Exception exception)
                {
                    exception.printStackTrace();
                }
                new MainFrame().setVisible(true);
            }
        });
    }

    private Model3D container3D;
    private Model3D pallet3D;
    private Model2D container2D;
    private Model2D pallet2D;
    private InputData inputData;
    private OutputData outputData;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private JButton jButton1;
    private JDesktopPane jDesktopPane1;
    private JInternalFrame jInternalFrame1;
    private JInternalFrame jInternalFrame2;
    private JInternalFrame jInternalFrame3;
    private JInternalFrame jInternalFrame4;
    private JLabel jLabel1;
    private JLabel jLabel2;
    private JLabel jLabel3;
    private JLabel jLabel4;
    private JLabel jLabel5;
    private JLabel jLabel6;
    private JLabel jLabel8;
    private JLabel jLabel9;
    private JPanel jPanel1;
    private JPanel jPanel2;
    private JPanel jPanel3;
    private JPanel jPanel4;
    private JPanel jPanel5;
    private JPanel jPanel6;
    private JPanel jPanel7;
    private JScrollPane jScrollPane1;
    private JScrollPane jScrollPane2;
    private JScrollPane jScrollPane3;
    private JScrollPane jScrollPane4;
    private JScrollPane jScrollPane5;
    private JScrollPane jScrollPane6;
    private JTabbedPane jTabbedPane1;
    private JTabbedPane jTabbedPane2;
    private JTabbedPane jTabbedPane3;
    private JTable jTable1;
    private JTable jTable2;
    private JTable jTable3;
    private JTable jTable4;
    private JTable jTable5;
    private JTable jTable6;
    private JTextField jTextField1;
    private JTextField jTextField2;
    private JTextField jTextField3;
    // End of variables declaration//GEN-END:variables

}
